package algoWing42.modelo;

import java.io.Serializable;

public class Punto implements Serializable {
		/**
	 * 
	 */
	private static final long serialVersionUID = -1495246956150343081L;
		private int x;
		private int y;
		
		public Punto(int x, int y){
			this.x=x;
			this.y=y;
			
		}
		public Punto(Punto posicion) {
			this.x = posicion.x;
			this.y = posicion.y;
		}
		public int getX(){
			return this.x;
			
		}
		public int getY(){
			return this.y;
			
		}
		
		public void setX(int pos) {
			this.x=pos;
		}
		
		public void setY(int pos) {
			this.y=pos;
		}
		public void sumar(Punto pto){
			this.x=this.x+pto.getX();
			this.y=this.y+pto.getY();
		}
		
		public Punto sumar(int i, int j) {
			// TODO Auto-generated method stub
			this.x=this.x+i;
			this.y=this.y+j;
			return this;
		}
		
		public Punto restar(Punto pto){
			int x,y;
			x=this.x-pto.getX();
			y=this.y-pto.getY();
			return new Punto(x,y);
		}
		
		public Punto restar(int posx, int posy) {
			this.x = this.x - posx;
			this.y = this.y - posy;
			return this;
		}
		
		public double distancia(Punto otro){
			int xd=this.getX()-otro.getX();
			int yd=this.getY()-otro.getY();
			return Math.sqrt(Math.pow(xd,2)+Math.pow(yd,2));
			}
		public Punto normalizarYRedondear(){
			double longitud = Math.sqrt(Math.pow(this.getX(),2)+Math.pow(this.getY(),2));
			double xd= (this.getX())/longitud;
			double yd= (this.getY())/longitud;
			int x = (int)Math.round(xd*2);
			int y = (int)Math.round(yd);
			return new Punto(x,y);
			
		}
		
		public boolean esIgualA(Punto otroPunto){
			return ((this.x==otroPunto.getX())&(this.y==otroPunto.getY()));
		}
		
		
}
